<?php
//Profilage
$time_start = microtime(true);
?>
<div class="titre"><?php echo(LOC_PORT_RESULTS); ?></div>
<p>
<?php
error_reporting(0);
$ip = $_SERVER['REMOTE_ADDR'];
function ping($ip, $port, $timeout){
    if($req = fsockopen($ip, $port, $errno, $errstr, $timeout)) {

        $type=getservbyport($port,"tcp");
        echo("<br>$type : OK</br>");
    }
    else {
        echo("<br>$type : ".LOC_ERROR."</br>");
    }
    fclose($req);
}
if(empty($_GET['port'])) {
ping($ip, 80, 3);
ping($ip, 21, 3);
ping($ip, 22, 3);
}
else {
echo(LOC_PORT);
echo($_GET['port']);
echo(LOC_ON);
echo($_GET['host']);
ping($_GET['host'], $_GET['port'], 3);
}
?>
</p>
<div class="titre"><?php echo(LOC_PORT_ANOTHER); ?></div>
<p align="center">
<br><?php echo(LOC_PORT_ENTER); ?></br>
<form method="GET" action="./index.php">
    <input type="hidden" name="page" value="portscan2" />
<p align="center"><?php echo(LOC_SERVER); ?>: <input type="text" name="host" /></p>
<p align="center">Port: <input type="text" name="port" /></p>
<p align="center"><input type="submit" /></p>
</form>
</p>
